package com.autumn.common.api.constants;

import java.io.Serializable;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

import com.autumn.common.api.domain.values.IntegerConstantItemValue;

/**
 * 基本档案状态
 * 
 * @author 杨昌国 2018-11-16 13:39:17
 */
public final class BasiscArchivesStatusConstant implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -7411777858062800496L;

	/**
	 * 启用
	 */
	public static final int ENABLE = 1;

	/**
	 * 禁用
	 */
	public static final int DISABLE = 2;

	/**
	 * 发布
	 */
	public static final int PUBLISH = 3;
	

	private static final Map<Integer, IntegerConstantItemValue> NAME_MAP = new HashMap<>();

	static {
		NAME_MAP.put(ENABLE, new IntegerConstantItemValue(ENABLE, "启用", "正常状态"));
		NAME_MAP.put(DISABLE, new IntegerConstantItemValue(DISABLE, "禁用", "不可使用"));
		NAME_MAP.put(PUBLISH, new IntegerConstantItemValue(PUBLISH, "发布", "处理发布状态"));
	}

	/**
	 * 是否存在
	 * 
	 * @param value
	 *            值
	 * @return
	 */
	public static boolean exist(Integer value) {
		if (value == null) {
			return false;
		}
		return NAME_MAP.containsKey(value);
	}

	/**
	 * 获取名称
	 * 
	 * @param value
	 *            值
	 * @return
	 */
	public static String getName(Integer value) {
		IntegerConstantItemValue item = NAME_MAP.get(value);
		if (item == null) {
			return "";
		}
		return item.getName();
	}

	/**
	 * 项目集合
	 * 
	 * @return
	 */
	public static Collection<IntegerConstantItemValue> items() {
		return NAME_MAP.values();
	}
}
